<?php
namespace Controllers;
class Common
{
    public function render ($tpl, $data = []) {
        extract($data); // $message $name
        $filename = './Views/' . $tpl . '.php';
        if (!file_exists($filename)) {
            echo 'The view ' . $tpl . ' is not exists';
            exit;
        }
        include_once $filename;
    }

    public function json_response($status = 1, $message = '', $data = null) {
        $result = compact('status', 'message', 'data');
        return json_encode($result);
    }
}